package com.sunlg.smarthome.ui.plant;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.List;

/**
 * Created by sunlg on 2017/5/27.
 */

public class PlantViewPagerAdapter extends FragmentPagerAdapter {
    private   List<Fragment> mFragments  ;//添加的Fragment的集合
    private   List<String>  Titles;//每个Fragment对应的title的集合
    public PlantViewPagerAdapter(FragmentManager fm, List<Fragment> fragments, List<String>titles) {
        super(fm);
        this.mFragments=fragments;
        this.Titles=titles;
    }

    @Override
    public Fragment getItem(int position) {
//得到对应position的Fragment
        return mFragments.get(position);
    }
    @Override
    public int getCount() {
//返回Fragment的数量
        return mFragments.size();
    }
    @Override
    public CharSequence getPageTitle(int position) {

        return Titles.get(position);
    }
}
